#ifndef DATABASE_H
#define DATABASE_H

#include <string>
#include <vector>
#include <map>
#include "user.h"
#include "Account.h"

class Database
{
public:
	Database();
	~Database();

	bool 				 UserExists( const std::string username );
	bool 				 IsValidUser( const std::string username, const std::string password );
	bool 				 AddUser( const std::string username, const std::string password);
	unsigned int AuthenticateUser(const std::string username, const std::string password);
	double 			 GetUserBalance( const unsigned int userHandle);
	void 				 EndUserSession( unsigned int const userHandle );
	bool				 UserLockedOut( const std::string username );

  void         DisplayAccounts ( const uint32_t userId ) ;

  void         CreateCannedAccounts () ;
  void         CreateCannedUsers () ;
  void         DumpAccounts () ;
  bool 				TransferFunds( const uint32_t userId,
  													 const uint32_t fromAcctID,
  													 const uint32_t toAcctID,
  													 const double amount );

private:
	// Prevent copy construction and assignment
	Database(const Database&);
	Database& operator=(const Database&);

	static const unsigned int MAX_FAILED_LOGINS = 3;

	std::vector< User* > pSystemUsers;
	typedef std::map<unsigned int, User*> AUTH_USERS_MAP;
	AUTH_USERS_MAP pAuthenticatedUsers;

  std::vector<Account> mAccounts ;
  std::multimap<uint32_t, uint32_t> mUserAccountsMap ;

};

#endif
